//
//  UIView+Extension.swift
//  SinaWeiBo
//
//  Created by 有风 on 16/2/23.
//  Copyright © 2016年 YouFeng. All rights reserved.
//

import UIKit

extension UIView {
    
    //遍历视图的响应者链条 获取导航视图控制器
    func navViewController() -> UINavigationController? {
        var next = nextResponder()
        
        while next != nil {
            
            if let nextObj = next as? UINavigationController {
                return nextObj
            }
            next = next!.nextResponder()
        }
        return nil
    }
    
}